document.querySelector('#tbody-list').addEventListener('click', function (e) {
    e = e || window.event
    let edit = e.target
    if (edit.nodeName === 'BUTTON' && edit.innerText === '编辑') {
        edit.parentNode.parentNode.classList.add('edit')
    }
    if (edit.nodeName === 'BUTTON' && edit.innerText === '确定') {
        edit.parentNode.parentNode.className = ''

        const tr = edit.parentNode.parentNode.querySelectorAll('td')
        const name = tr[1].querySelector('input').value;
        const sp1 = tr[1].querySelector('span')
        sp1.innerText = name

        const price = tr[2].querySelector('input').value;
        const sp2 = tr[2].querySelector('span')
        sp2.innerText = price

        const num = tr[3].querySelector('input').value;
        const sp3 = tr[3].querySelector('span')
        sp3.innerText = num

        const id = edit.parentNode.parentNode.getAttribute('data-id')

        utils.fetch('./api/v1/shop/edit.php', { id, name, price, num }).then(resp => {
            if (resp.code === 200) {
                console.log(123);

            }
        })
    }
    if (edit.nodeName === 'BUTTON' && edit.innerText === '取消') {
        edit.parentNode.parentNode.className = ''
    }
})